<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"wan-lei8.gitee.io","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="拼团流程">
<meta property="og:type" content="article">
<meta property="og:title" content="WorkSummary_Collage">
<meta property="og:url" content="https://wan-lei8.gitee.io/2021/08/16/WorkSummary-Collage/index.html">
<meta property="og:site_name" content="程序员西桐">
<meta property="og:description" content="拼团流程">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="c:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/image-20211216151703748.png">
<meta property="og:image" content="c:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/image-20211216151901635.png">
<meta property="og:image" content="c:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/image-20211216161312795.png">
<meta property="og:image" content="c:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/image-20211216164516832.png">
<meta property="og:image" content="c:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/image-20211216164638137.png">
<meta property="og:image" content="c:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/image-20211217141222782.png">
<meta property="article:published_time" content="2021-08-16T07:11:39.000Z">
<meta property="article:modified_time" content="2021-12-17T08:07:36.824Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="c:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/image-20211216151703748.png">

<link rel="canonical" href="https://wan-lei8.gitee.io/2021/08/16/WorkSummary-Collage/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>WorkSummary_Collage | 程序员西桐</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">程序员西桐</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">但行好事，莫问前程</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://wan-lei8.gitee.io/2021/08/16/WorkSummary-Collage/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="程序员西桐">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          WorkSummary_Collage
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-08-16 15:11:39" itemprop="dateCreated datePublished" datetime="2021-08-16T15:11:39+08:00">2021-08-16</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-12-17 16:07:36" itemprop="dateModified" datetime="2021-12-17T16:07:36+08:00">2021-12-17</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h4 id="拼团流程"><a href="#拼团流程" class="headerlink" title="拼团流程"></a>拼团流程</h4><span id="more"></span>

<ol>
<li><strong>用户登录可以在首页进入合伙人拼团发起拼团</strong></li>
</ol>
<p><img src="C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211216151703748.png" alt="image-20211216151703748"></p>
<ol start="2">
<li><strong>进入合伙人拼团查询进行中的团，用户可以发起拼团</strong></li>
</ol>
<p><img src="C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211216151901635.png" alt="image-20211216151901635"></p>
<ul>
<li>查询进行中的团</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//请求参数</span></span><br><span class="line"><span class="meta">@Data</span></span><br><span class="line"><span class="meta">@ApiModel(value = &quot;GshoppingSkuSharePageRequest&quot;, description = &quot;模块分享商品sku关联表分页查询请求&quot;, parent = AbstractRequest.class)</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">GshoppingSkuSharePageRequest</span> <span class="keyword">extends</span> <span class="title">AbstractPageRequest</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@ApiModelProperty(value = &quot;1：已结束，3：进行中，4:未开始&quot;)</span></span><br><span class="line">    <span class="keyword">private</span> Integer state;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">checkParam</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">super</span>.checkParam();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> OperationType <span class="title">getOperationType</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> GshoppingSkuOperationType.GSHOPPING_SKU_PAGE;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>封装参数查询拼团活动表</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Override</span></span><br><span class="line"><span class="keyword">public</span> Response&lt;Paging&lt;GshareInfoListResponse&gt;&gt; sharePageList(SpellGroupListPageRequest request) &#123;</span><br><span class="line">    Map&lt;String, Object&gt; params = <span class="keyword">new</span> HashMap&lt;&gt;();</span><br><span class="line">    params.put(<span class="string">&quot;tenantId&quot;</span>, request.getTenantId());</span><br><span class="line">    params.put(<span class="string">&quot;operatorId&quot;</span>, request.getOperatorId());</span><br><span class="line"></span><br><span class="line">    params.put(<span class="string">&quot;shardNo&quot;</span>, String.valueOf(request.getOperatorId()));</span><br><span class="line">    params.put(<span class="string">&quot;userId&quot;</span>, request.getUserId());</span><br><span class="line"></span><br><span class="line">    PageInfo pageInfo = <span class="keyword">new</span> PageInfo(request.getPageNo(), request.getPageSize());</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (request.getState() != <span class="keyword">null</span>) &#123;</span><br><span class="line">        params.put(<span class="string">&quot;gshoppingState&quot;</span>, request.getState());</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    Paging&lt;GshoppingInfoModel&gt; gshoppingInfoModelPage</span><br><span class="line">            = gshoppingInfoReadService.sharePages(params, pageInfo.getOffset(), pageInfo.getLimit());</span><br></pre></td></tr></table></figure>

<p>根据拼团活动信息获取其它拼团信息</p>
<ul>
<li>获取拼团商品信息</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">private</span> List&lt;GshareInfoListResponse&gt; <span class="title">shareListHandle</span><span class="params">(List&lt;GshoppingInfoModel&gt; gshoppingInfoModelList,</span></span></span><br><span class="line"><span class="params"><span class="function">                                                         Long operatorId,</span></span></span><br><span class="line"><span class="params"><span class="function">                                                         Integer tenantId,</span></span></span><br><span class="line"><span class="params"><span class="function">                                                         String status)</span> </span>&#123;</span><br><span class="line">        <span class="comment">// item商品参数集合</span></span><br><span class="line">        List&lt;Long&gt; gsIds = gshoppingInfoModelList.stream().map(GshoppingInfoModel::getId).collect(Collectors.toList());</span><br><span class="line">        <span class="keyword">if</span> (gsIds.size() == <span class="number">0</span>) &#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">new</span> ArrayList&lt;&gt;();</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 获取商品信息根据gsid</span></span><br><span class="line">        List&lt;GshoppingItemModel&gt; modelList = gshoppingItemReadService.gsIdByList(gsIds, operatorId);</span><br><span class="line">        <span class="keyword">if</span> (ObjectUtil.isEmpty(modelList)) &#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">new</span> ArrayList&lt;&gt;();</span><br><span class="line">        &#125;</span><br><span class="line">    </span><br><span class="line">        Map&lt;Long, GshoppingItemModel&gt; modelGSMap</span><br><span class="line">                = CollectionObjectUtils.toMap(modelList, GshoppingItemModel::getGsId);</span><br><span class="line"></span><br><span class="line">        List&lt;Long&gt; itemIds = modelList.stream().map(GshoppingItemModel::getItemId).collect(Collectors.toList());</span><br></pre></td></tr></table></figure>

<ul>
<li>根据活动id和参团人数获取该拼团订单信息</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="comment">// 订单参数集合 gsId gsNum</span></span><br><span class="line">List&lt;OrderGsShoppingQueryRequest&gt; orderReqList =</span><br><span class="line">        gshoppingInfoModelList</span><br><span class="line">                .stream()</span><br><span class="line">                .map(gshoppingInfoModel -&gt; &#123;</span><br><span class="line">                    OrderGsShoppingQueryRequest orderReq = <span class="keyword">new</span> OrderGsShoppingQueryRequest();</span><br><span class="line">                    orderReq.setGsId(gshoppingInfoModel.getId());</span><br><span class="line">                    orderReq.setGshoppingConditionNum(gshoppingInfoModel.getGshoppingNum());</span><br><span class="line">                    <span class="keyword">return</span> orderReq;</span><br><span class="line">                &#125;).collect(Collectors.toList());</span><br><span class="line"><span class="comment">// 获取订单集合,根据订单参数集合--gsId和参与人数--不同</span></span><br><span class="line">ApiResponse&lt;List&lt;OrderGsShoppingStatisticInfo&gt;&gt; orderInfoList</span><br><span class="line">        = orderStatisticQueryFacade.yjrGsShoppingOrderStatistics(orderReqList, tenantId, operatorId);</span><br></pre></td></tr></table></figure>

<ul>
<li>根据商品id获取商品主图</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 商品主图参数</span></span><br><span class="line"> AreaItemQueryByOperatorIdAndItemIdsRequest queryByOperatorIdAndItemIdsRequest</span><br><span class="line">         = <span class="keyword">new</span> AreaItemQueryByOperatorIdAndItemIdsRequest();</span><br><span class="line"> queryByOperatorIdAndItemIdsRequest.setOperatorId(modelList.get(<span class="number">0</span>).getOperatorId());</span><br><span class="line"> queryByOperatorIdAndItemIdsRequest.setItemIds(<span class="keyword">new</span> HashSet&lt;&gt;(itemIds));</span><br><span class="line"></span><br><span class="line"> <span class="comment">// 根据商品主图参数 获取主图--同OperatorId 不同itemid</span></span><br><span class="line"> Response&lt;List&lt;AreaItemInfo&gt;&gt; areaItemInfoResponseList</span><br><span class="line">         = areaItemReadFacade.queryByItemIds(queryByOperatorIdAndItemIdsRequest);</span><br></pre></td></tr></table></figure>

<ul>
<li>根据商品获取对应商品价格列表</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//根据商品拿到对应商品价格列表--itemId不同</span></span><br><span class="line">List&lt;Map&lt;String, Object&gt;&gt; priceList = gshoppingSkuReadService.itemIdByPriceList(itemIds, gsIds, operatorId);</span><br><span class="line">Map&lt;Object, Map&lt;String, Object&gt;&gt; priceMap = <span class="keyword">new</span> HashMap&lt;&gt;();</span><br><span class="line"><span class="keyword">if</span> (priceList.size() != <span class="number">0</span>) &#123;</span><br><span class="line">    priceMap = CollectionObjectUtils.toMap(priceList, x -&gt; x.get(<span class="string">&quot;gs_id&quot;</span>));</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>对应sql</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">&lt;select id=&quot;itemIdByPrice&quot; parameterType=&quot;list&quot; resultType=&quot;java.util.HashMap&quot;&gt;</span><br><span class="line">        SELECT</span><br><span class="line">        MAX(price) AS priceMax,MIN(price) as priceMin , item_id ,gs_id</span><br><span class="line">        FROM</span><br><span class="line">        &lt;include refid=&quot;table_name&quot;/&gt;</span><br><span class="line">        &lt;where&gt;</span><br><span class="line">            &lt;if test=&quot;list != null and list.size()!=0 &quot;&gt;</span><br><span class="line">                and item_id IN</span><br><span class="line">                &lt;foreach item=&quot;itemId&quot; collection=&quot;list&quot; open=&quot;(&quot; separator=&quot;,&quot; close=&quot;)&quot;&gt;</span><br><span class="line">                    #&#123;itemId&#125;</span><br><span class="line">                &lt;/foreach&gt;</span><br><span class="line">            &lt;/if&gt;</span><br><span class="line">            &lt;if test=&quot;gsIds != null and gsIds.size()!=0 &quot;&gt;</span><br><span class="line">                AND gs_id IN</span><br><span class="line">                &lt;foreach item=&quot;gs_id&quot; collection=&quot;gsIds&quot; open=&quot;(&quot; separator=&quot;,&quot; close=&quot;)&quot;&gt;</span><br><span class="line">                    #&#123;gs_id&#125;</span><br><span class="line">                &lt;/foreach&gt;</span><br><span class="line">            &lt;/if&gt;</span><br><span class="line">            &lt;if test=&quot;tenantId != null&quot;&gt;AND tenant_id = #&#123;tenantId&#125;&lt;/if&gt;</span><br><span class="line">            &lt;if test=&quot;operatorId != null&quot;&gt;AND operator_id = #&#123;operatorId&#125;&lt;/if&gt;</span><br><span class="line">            &lt;if test=&quot;shardNo != null&quot;&gt;AND shard_no = #&#123;shardNo&#125;&lt;/if&gt;</span><br><span class="line">            GROUP BY item_id,gs_id</span><br><span class="line">        &lt;/where&gt;</span><br><span class="line">    &lt;/select&gt;</span><br></pre></td></tr></table></figure>

<ul>
<li>根据商品获取购买价格</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 商品购买价格</span></span><br><span class="line">      AreaPrimarySearchRequest areaPrimarySearchRequest = <span class="keyword">new</span> AreaPrimarySearchRequest();</span><br><span class="line">      StringBuffer itemIdStr = <span class="keyword">new</span> StringBuffer();</span><br><span class="line">      <span class="keyword">int</span> i = <span class="number">1</span>;</span><br><span class="line">      <span class="keyword">for</span> (Long itemId : itemIds) &#123;</span><br><span class="line">          itemIdStr.append(itemId);</span><br><span class="line">          <span class="keyword">if</span> (ObjectUtil.notEqual(itemIds.size(), i)) &#123;</span><br><span class="line">              itemIdStr.append(<span class="string">&quot;,&quot;</span>);</span><br><span class="line">          &#125;</span><br><span class="line">          i++;</span><br><span class="line">      &#125;</span><br><span class="line"></span><br><span class="line">      areaPrimarySearchRequest.setItemIds(String.valueOf(itemIdStr));</span><br><span class="line">      areaPrimarySearchRequest.setTenantId(tenantId);</span><br><span class="line">      areaPrimarySearchRequest.setOperatorIds(Sets.newHashSet(Long.valueOf(operatorId)));</span><br><span class="line"></span><br><span class="line">      Response&lt;List&lt;AreaFrontItemDTO&gt;&gt; areaFrontItemDTOResponse =</span><br><span class="line">              primarySearchFacade.gShoppingSearchShare(areaPrimarySearchRequest);</span><br><span class="line">      <span class="keyword">if</span> (!areaFrontItemDTOResponse.isSuccess()) &#123;</span><br><span class="line">          <span class="keyword">return</span> <span class="keyword">new</span> ArrayList&lt;&gt;();</span><br><span class="line">      &#125;</span><br><span class="line">      Map&lt;Long, AreaFrontItemDTO&gt; areaFrontItemDTOResponseMap =</span><br><span class="line">              CollectionObjectUtils.toMap(areaFrontItemDTOResponse.getResult(), AreaFrontItemDTO::getItemId);</span><br></pre></td></tr></table></figure>

<ul>
<li>封装返回结果</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">for</span> (GshoppingInfoModel gshoppingInfoModel : gshoppingInfoModelList) &#123;</span><br><span class="line">            GshareInfoListResponse response = <span class="keyword">new</span> GshareInfoListResponse();</span><br><span class="line"></span><br><span class="line">            <span class="keyword">try</span> &#123;</span><br><span class="line">                OrderGsShoppingStatisticInfo orderGsShoppingStatisticInfo = orderInfoMap.get(gshoppingInfoModel.getId());</span><br><span class="line">                <span class="keyword">if</span> (ObjectUtil.isNull(orderGsShoppingStatisticInfo)) &#123;</span><br><span class="line">                    orderInfoMap.put(gshoppingInfoModel.getId(), <span class="keyword">new</span> OrderGsShoppingStatisticInfo());</span><br><span class="line">                &#125;</span><br><span class="line"></span><br><span class="line">                Map&lt;String, Object&gt; price = priceMap.get(gshoppingInfoModel.getId());</span><br><span class="line">                <span class="keyword">if</span> (price != <span class="keyword">null</span>) &#123;</span><br><span class="line">                    response.setMinPrice(</span><br><span class="line">                            Long.valueOf(</span><br><span class="line">                                    String.valueOf(Optional.ofNullable(price.get(<span class="string">&quot;priceMin&quot;</span>)).orElse(<span class="number">0L</span>))));</span><br><span class="line">                    response.setMaxPrice(</span><br><span class="line">                            Long.valueOf(</span><br><span class="line">                                    String.valueOf(Optional.ofNullable(price.get(<span class="string">&quot;priceMax&quot;</span>)).orElse(<span class="number">0L</span>))));</span><br><span class="line">                &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                    response.setMinPrice(<span class="number">0L</span>);</span><br><span class="line">                    response.setMaxPrice(<span class="number">0L</span>);</span><br><span class="line">                &#125;</span><br><span class="line">                AreaFrontItemDTO areaFrontItemDTO</span><br><span class="line">                        = Optional.ofNullable(</span><br><span class="line">                        areaFrontItemDTOResponseMap.get(</span><br><span class="line">                                modelGSMap.get(gshoppingInfoModel.getId()).getItemId())).orElse(<span class="keyword">new</span> AreaFrontItemDTO());</span><br><span class="line"></span><br><span class="line">                <span class="comment">// 组装相关数据</span></span><br><span class="line">                response.setBuyPrice(Optional.ofNullable(areaFrontItemDTO.getLowOriginalPrice()).orElse(<span class="number">0L</span>));</span><br><span class="line">                response.setGShoppingNum(gshoppingInfoModel.getGshoppingNum());</span><br><span class="line">                response.setState(gshoppingInfoModel.getGshoppingState());</span><br><span class="line">                response.setId(gshoppingInfoModel.getId());</span><br><span class="line">                response.setStartAt(gshoppingInfoModel.getStartAt());</span><br><span class="line">                response.setExpiredAt(gshoppingInfoModel.getExpiredAt());</span><br><span class="line"></span><br><span class="line">                response.setItemName(modelGSMap.get(gshoppingInfoModel.getId()).getItemName());</span><br><span class="line">                response.setItemId(modelGSMap.get(gshoppingInfoModel.getId()).getItemId());</span><br><span class="line">                response.setPurchasingNum(modelGSMap.get(gshoppingInfoModel.getId()).getPurchasingNum());</span><br><span class="line">                response.setMainImage(</span><br><span class="line">                        areaItemInfoResponseMap.get(modelGSMap.get(gshoppingInfoModel.getId()).getItemId()).getMainImage());</span><br><span class="line">                response.setPeopleNum(</span><br><span class="line">                        Optional.ofNullable(orderInfoMap.get(gshoppingInfoModel.getId()).getTeamNum()).orElse(<span class="number">0L</span>));</span><br><span class="line">                response.setOrderNum(</span><br><span class="line">                        Optional.ofNullable(orderInfoMap.get(gshoppingInfoModel.getId()).getOrderNum()).orElse(<span class="number">0</span>));</span><br><span class="line">                <span class="keyword">if</span> (StrUtil.equals(<span class="string">&quot;sharePageList&quot;</span>, status)) &#123;</span><br><span class="line">                    response.setSalesAmount(</span><br><span class="line">                            Optional.ofNullable(orderInfoMap.get(gshoppingInfoModel.getId()).getSalesMoney()).orElse(<span class="number">0L</span>));</span><br><span class="line">                    response.setAnticipatedIncome(</span><br><span class="line">                            Optional.ofNullable(orderInfoMap.get(gshoppingInfoModel.getId()).getPreEarnings()).orElse(<span class="number">0L</span>));</span><br><span class="line">                &#125;</span><br><span class="line">                response.setGShoppingPeopleNum(</span><br><span class="line">                        Optional.ofNullable(orderInfoMap.get(gshoppingInfoModel.getId()).getPeopleNum()).orElse(<span class="number">0</span>));</span><br><span class="line">                gshareInfoListResponseList.add(response);</span><br><span class="line">            &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">                log.info(<span class="string">&quot;异常信息:&#123;&#125;&quot;</span>, response);</span><br><span class="line">            &#125;</span><br><span class="line">            log.info(<span class="string">&quot;信息1111111:&#123;&#125;&quot;</span>, response);</span><br><span class="line">        &#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>用户选择商品发起拼团</li>
</ul>
<p><img src="C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211216161312795.png" alt="image-20211216161312795"></p>
<ul>
<li>填写相关信息创建拼团活动</li>
</ul>
<ol start="3">
<li><strong>创建拼团活动参数校验</strong></li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Data</span></span><br><span class="line"><span class="meta">@ApiModel(value = &quot;SpellGroupCreateRequest&quot;, description = &quot;拼团信息表创建请求&quot;, parent = AbstractRequest.class)</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">SpellGroupCreateRequest</span> <span class="keyword">extends</span> <span class="title">AbstractRequest</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">	<span class="meta">@ApiModelProperty(value = &quot;活动ID&quot;)</span></span><br><span class="line">	<span class="keyword">private</span> Long id;</span><br><span class="line"></span><br><span class="line">	<span class="meta">@ApiModelProperty(value = &quot;成团人数&quot;)</span></span><br><span class="line">	<span class="keyword">private</span> Integer gshoppingNum;</span><br><span class="line"></span><br><span class="line"><span class="comment">//	@ApiModelProperty(value = &quot;成团时间(天)&quot;)</span></span><br><span class="line"><span class="comment">//	private Integer groupsTime;</span></span><br><span class="line"></span><br><span class="line">	<span class="meta">@ApiModelProperty(value = &quot;开始时间&quot;)</span></span><br><span class="line">	<span class="meta">@JsonFormat(pattern=&quot;yyyy-MM-dd hh:mm&quot;,timezone=&quot;GMT+8&quot;)</span></span><br><span class="line">	<span class="keyword">private</span> java.util.Date startAt;</span><br><span class="line"></span><br><span class="line">	<span class="meta">@ApiModelProperty(value = &quot;结束时间&quot;)</span></span><br><span class="line">	<span class="meta">@JsonFormat(pattern=&quot;yyyy-MM-dd hh:mm&quot;,timezone=&quot;GMT+8&quot;)</span></span><br><span class="line">	<span class="keyword">private</span> java.util.Date expiredAt;</span><br><span class="line"></span><br><span class="line">	<span class="meta">@ApiModelProperty(value = &quot;商品ID&quot;)</span></span><br><span class="line">	<span class="keyword">private</span> Long itemId;</span><br><span class="line"></span><br><span class="line">	<span class="meta">@ApiModelProperty(value = &quot;限购件数&quot;)</span></span><br><span class="line">	<span class="keyword">private</span> Integer purchasingNum;</span><br><span class="line"></span><br><span class="line">	<span class="meta">@ApiModelProperty(value = &quot;拼团SKU信息&quot;)</span></span><br><span class="line">	<span class="keyword">private</span> List&lt;SkuGroupInfo&gt; skuGroupInfos;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 用户id</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="meta">@ApiModelProperty(value = &quot;当前用户Id&quot;,hidden = true)</span></span><br><span class="line">	<span class="keyword">private</span> Long userId;</span><br><span class="line"></span><br><span class="line">	<span class="meta">@ApiModelProperty(value = &quot;区域ID&quot;,hidden = true)</span></span><br><span class="line">	<span class="keyword">private</span> Long operatorId;</span><br><span class="line"></span><br><span class="line">	<span class="meta">@ApiModelProperty(value = &quot;商品名称&quot;,hidden = true)</span></span><br><span class="line">	<span class="keyword">private</span> String itemName;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">	<span class="meta">@ApiModelProperty(value = &quot;创建人&quot;,hidden = true)</span></span><br><span class="line">	<span class="keyword">private</span> String createrBy;</span><br><span class="line"></span><br><span class="line">	<span class="meta">@Override</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">checkParam</span><span class="params">()</span> </span>&#123;</span><br><span class="line">		<span class="keyword">super</span>.checkParam();</span><br><span class="line">		ParamUtil.nonNull(startAt, <span class="string">&quot;活动开始时间不能为空&quot;</span>);</span><br><span class="line">		ParamUtil.nonNull(expiredAt, <span class="string">&quot;活动结束时间不能为空&quot;</span>);</span><br><span class="line"><span class="comment">//		ParamUtil.nonNull(groupsTime, &quot;成团时间不能空位&quot;);</span></span><br><span class="line">		ParamUtil.nonNull(itemId, <span class="string">&quot;商品ID不能空位&quot;</span>);</span><br><span class="line">		ParamUtil.nonNull(purchasingNum, <span class="string">&quot;限购件数不能空位&quot;</span>);</span><br><span class="line">		ParamUtil.nonNull(gshoppingNum, <span class="string">&quot;拼团人数不能空位&quot;</span>);</span><br><span class="line">		<span class="keyword">if</span> (gshoppingNum &lt; <span class="number">2</span>) &#123;</span><br><span class="line">			<span class="keyword">throw</span> <span class="keyword">new</span> IllegalArgumentException(<span class="string">&quot;拼团人数必须为2个人以上&quot;</span>);</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">if</span> (expiredAt.getTime() &lt;= startAt.getTime()) &#123;</span><br><span class="line">			<span class="keyword">throw</span> <span class="keyword">new</span> IllegalArgumentException(<span class="string">&quot;活动结束时间需大于活动开始时间&quot;</span>);</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">int</span> days = (<span class="keyword">int</span>) ((expiredAt.getTime() - startAt.getTime()) / (<span class="number">1000</span> * <span class="number">3600</span> * <span class="number">24</span>));</span><br><span class="line">		<span class="keyword">if</span> (days &gt; <span class="number">3</span>) &#123;</span><br><span class="line">			<span class="keyword">throw</span> <span class="keyword">new</span> IllegalArgumentException(<span class="string">&quot;活动时间不能超过3天&quot;</span>);</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">if</span> (CollectionUtils.isEmpty(skuGroupInfos)) &#123;</span><br><span class="line">			<span class="keyword">throw</span> <span class="keyword">new</span> IllegalArgumentException(<span class="string">&quot;拼团SKU信息不能为空&quot;</span>);</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> OperationType <span class="title">getOperationType</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> SpellGroupOperationType.SPELL_GROUP_CREATE;</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>创建活动前检验当前用户该商品是否正参与活动</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">GshoppingInfoModel getUserGsModel =  <span class="keyword">new</span> GshoppingInfoModel();</span><br><span class="line">getUserGsModel.setUserId(request.getUserId());</span><br><span class="line">getUserGsModel.setStartAt(request.getStartAt());</span><br><span class="line">getUserGsModel.setExpiredAt(request.getExpiredAt());</span><br><span class="line">getUserGsModel.setGshoppingType(GshoppingType.GSHOPPING_TYPE_1.resolve());</span><br><span class="line">getUserGsModel.setShardNo(request.getOperatorId().toString());</span><br><span class="line">List&lt;GshoppingInfoModel&gt; findByUserList = gshoppingInfoReadService.findByUserIds(getUserGsModel);</span><br><span class="line"><span class="keyword">if</span> (!CollectionUtils.isEmpty(findByUserList))&#123;</span><br><span class="line">	log.info(<span class="string">&quot;SpellGroupWriteFacadeImpl create is not null&quot;</span>);</span><br><span class="line">	List&lt;Long&gt; gsIds = findByUserList.stream().map(GshoppingInfoModel::getId).collect(Collectors.toList());</span><br><span class="line">	String shardNo=getUserGsModel.getShardNo();</span><br><span class="line">	List&lt;GshoppingItemModel&gt; gsIdsResult = gshoppingItemReadService.findGsIds(shardNo,gsIds,request.getItemId());</span><br><span class="line">	<span class="keyword">if</span> (!CollectionUtils.isEmpty(gsIdsResult))&#123;</span><br><span class="line">		<span class="keyword">return</span> Response.fail(PromotionErrorCode.SPELL_GROUP_CREATE_ITEM_MANY.getMessage());</span><br><span class="line">	&#125;</span><br><span class="line">	log.info(<span class="string">&quot;SpellGroupWriteFacadeImpl create is not null&#123;&#125;&quot;</span>,JSONObject.toJSONString(gsIdsResult));</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>校验商品起售</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">AreaSkuQueryBySingleItemIdRequest areaSkuQueryBySingleItemIdRequest = <span class="keyword">new</span> AreaSkuQueryBySingleItemIdRequest();</span><br><span class="line">		areaSkuQueryBySingleItemIdRequest.setItemId(request.getItemId());</span><br><span class="line">		areaSkuQueryBySingleItemIdRequest.setOperatorId(request.getOperatorId());</span><br><span class="line">		log.info(<span class="string">&quot;create call areaSkuReadFacade.queryBySingleItemId minQuantity:&#123;&#125;&quot;</span>,areaSkuQueryBySingleItemIdRequest);</span><br><span class="line">		Response&lt;List&lt;AreaSkuInfo&gt;&gt; response = areaSkuReadFacade.queryBySingleItemId(areaSkuQueryBySingleItemIdRequest);</span><br><span class="line">		log.info(<span class="string">&quot;create call areaSkuReadFacade.queryBySingleItemId result:&#123;&#125;&quot;</span>,response);</span><br><span class="line">		<span class="keyword">if</span> (<span class="keyword">null</span> ==response || <span class="keyword">null</span> == response.getResult())&#123;</span><br><span class="line">			<span class="keyword">return</span> Response.fail(PromotionErrorCode.SPELL_GROUP_SKU_NON.getMessage());</span><br><span class="line">		&#125;</span><br><span class="line">		Long minQuantity = response.getResult().stream().mapToLong(x-&gt;x.getMinQuantity()).max().orElse(<span class="number">0L</span>);</span><br><span class="line">		log.info(<span class="string">&quot;create minQuantity:&#123;&#125;&quot;</span>,minQuantity);</span><br><span class="line">		<span class="keyword">if</span> (request.getPurchasingNum()&gt;<span class="number">0</span>)&#123;</span><br><span class="line">			log.info(<span class="string">&quot;create request.getPurchasingNum() &lt; minQuantity:&#123;&#125;&quot;</span>,request.getPurchasingNum() &lt; minQuantity);</span><br><span class="line">			<span class="keyword">if</span> (request.getPurchasingNum() &lt; minQuantity)&#123;</span><br><span class="line">				<span class="keyword">return</span> Response.fail(String.format(PromotionErrorCode.SPELL_GROUP_PURCHASING_NUM.getMessage(), minQuantity));</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>校验商品信息</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">AreaItemQueryByOperatorIdAndItemIdRequest var1 =  <span class="keyword">new</span> AreaItemQueryByOperatorIdAndItemIdRequest();</span><br><span class="line">var1.setItemId(request.getItemId());</span><br><span class="line">var1.setOperatorId(request.getOperatorId());</span><br><span class="line">log.info(<span class="string">&quot;SpellGroupWriteFacadeImpl call queryFullAreaItem var1&#123;&#125;&quot;</span>,JSONObject.toJSONString(var1));</span><br><span class="line">Response&lt;AreaItemInfo&gt; areaItemInfoResponse = areaItemReadFacade.queryByItemId(var1);</span><br><span class="line">log.info(<span class="string">&quot;SpellGroupWriteFacadeImpl saveGshoppingItem &#123;&#125;&quot;</span>,JSONObject.toJSONString(areaItemInfoResponse));</span><br><span class="line"><span class="comment">//end 调用查询商品信息</span></span><br><span class="line"><span class="keyword">if</span> (<span class="keyword">null</span> == areaItemInfoResponse</span><br><span class="line">		|| <span class="keyword">null</span> == areaItemInfoResponse.getResult()</span><br><span class="line">)&#123;</span><br><span class="line">	<span class="keyword">return</span> Response.fail( PromotionErrorCode.SPELL_GROUP_SKU_NON.getMessage());</span><br><span class="line">&#125;</span><br><span class="line">request.setItemName(areaItemInfoResponse.getResult().getName());</span><br></pre></td></tr></table></figure>

<ul>
<li>校验平团设置价格</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/***</span></span><br><span class="line"><span class="comment">	 * 校验拼团设置价格</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> request</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="function"><span class="keyword">private</span> SpellGroupCheckPriceResponse <span class="title">checkSkuPrice</span><span class="params">(SpellGroupItemPriceRequest request)</span></span>&#123;</span><br><span class="line">		SpellGroupCheckPriceResponse spellGroupCheckPriceResponse = <span class="keyword">new</span> SpellGroupCheckPriceResponse();</span><br><span class="line">		<span class="keyword">boolean</span> result = <span class="keyword">true</span>;</span><br><span class="line">		AreaSkuQueryByGroupBuyInfoRequest itemPriceRequest = <span class="keyword">new</span> AreaSkuQueryByGroupBuyInfoRequest();</span><br><span class="line">		itemPriceRequest.setOperatorId(request.getOperatorId());</span><br><span class="line">		itemPriceRequest.setItemId(request.getItemId());</span><br><span class="line">		itemPriceRequest.setUserId(request.getUserId());</span><br><span class="line">		log.info(<span class="string">&quot;SpellGroupWriteFacadeImpl checkSkuPrice-&gt;queryByGroupBuy:&#123;&#125;&quot;</span>,JSONObject.toJSONString(itemPriceRequest));</span><br><span class="line">		Response&lt;List&lt;AreaSkuGroupBuyInfo&gt;&gt; querSkuRep = areaSkuGroupBuyReadFacade.queryByGroupBuy(itemPriceRequest);</span><br><span class="line">		log.info(<span class="string">&quot;checkSkuPrice:&#123;&#125;&quot;</span>,JSONObject.toJSONString(querSkuRep));</span><br><span class="line">		<span class="keyword">if</span> (<span class="keyword">null</span> != querSkuRep &amp;&amp; querSkuRep.isSuccess() &amp;&amp; !CollectionUtils.isEmpty(querSkuRep.getResult()))&#123;</span><br><span class="line">			List&lt;AreaSkuGroupBuyInfo&gt; areaSkuInfoList = querSkuRep.getResult();</span><br><span class="line">			log.info(<span class="string">&quot;checkSkuPrice JSONObject.toJSONString(areaSkuInfoList):&#123;&#125;&quot;</span>,JSONObject.toJSONString(request.getSkuGroupInfos()));</span><br><span class="line">			Map&lt;Long,SkuGroupInfo&gt; skuGroupInfoMap = request.getSkuGroupInfos().stream().collect(Collectors.toMap(SkuGroupInfo::getSkuId, x -&gt; x));</span><br><span class="line">			<span class="keyword">for</span> (AreaSkuGroupBuyInfo areaSkuInfo : areaSkuInfoList)&#123;</span><br><span class="line">				<span class="keyword">if</span> (<span class="keyword">null</span> == skuGroupInfoMap.get(areaSkuInfo.getSkuId()))&#123;</span><br><span class="line">					result =<span class="keyword">false</span>;</span><br><span class="line">					spellGroupCheckPriceResponse.setError(PromotionErrorCode.SPELL_GROUP_ITEM_SKU_NON.getMessage());</span><br><span class="line">					<span class="keyword">break</span>;</span><br><span class="line">				&#125;</span><br><span class="line">				<span class="keyword">if</span> (<span class="keyword">null</span> == areaSkuInfo.getReferencePrice())&#123;</span><br><span class="line">					result =<span class="keyword">false</span>;</span><br><span class="line">					spellGroupCheckPriceResponse.setError(PromotionErrorCode.SPELL_GROUP_ITEM_SKU_PRICE.getMessage());</span><br><span class="line">					<span class="keyword">break</span>;</span><br><span class="line">				&#125;</span><br><span class="line">				SkuGroupInfo skuGroupInfo = skuGroupInfoMap.get(areaSkuInfo.getSkuId());</span><br><span class="line">				log.info(<span class="string">&quot;call areaSkuGroupBuyReadFacade.queryByGroupBuy skuGroupInfo.getPrice()&#123;&#125;&quot;</span></span><br><span class="line">						,JSONObject.toJSONString(skuGroupInfo));</span><br><span class="line">				<span class="keyword">if</span> (skuGroupInfo.getPrice().compareTo(areaSkuInfo.getReferencePrice()) == -<span class="number">1</span>)&#123;</span><br><span class="line">					log.info(<span class="string">&quot;call areaSkuGroupBuyReadFacade.queryByGroupBuy skuGroupInfo.getPrice().compareTo(areaSkuInfo.getReferencePrice()) == -1&quot;</span>);</span><br><span class="line">					result =<span class="keyword">false</span>;</span><br><span class="line">					spellGroupCheckPriceResponse.setError(PromotionErrorCode.SPELL_GROUP_SKU_PRICE.getMessage());</span><br><span class="line">					<span class="keyword">break</span>;</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;<span class="keyword">else</span> &#123;</span><br><span class="line">			log.info(<span class="string">&quot;call areaSkuGroupBuyReadFacade.queryByGroupBuy result is null&#123;&#125;&quot;</span>,querSkuRep.getError());</span><br><span class="line">			spellGroupCheckPriceResponse.setError(querSkuRep.getError());</span><br><span class="line">			result = <span class="keyword">false</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		spellGroupCheckPriceResponse.setResult(result);</span><br><span class="line">		<span class="keyword">return</span> spellGroupCheckPriceResponse;</span><br><span class="line">	&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>校验全部通过创建拼团活动</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">private</span> Long <span class="title">saveGshoppingInfo</span><span class="params">(SpellGroupCreateRequest request)</span> </span>&#123;</span><br><span class="line">		GshoppingInfoModel model = <span class="keyword">new</span> GshoppingInfoModel();</span><br><span class="line">		model.setCreaterBy(request.getCreaterBy());</span><br><span class="line">		model.setUpdatedBy(request.getCreaterBy());</span><br><span class="line">		model.setUserId(request.getUserId());</span><br><span class="line">		model.setOperatorId(<span class="keyword">new</span> Long(request.getOperatorId()));</span><br><span class="line">		model.setTenantId(<span class="keyword">new</span> Long(request.getTenantId()));</span><br><span class="line">		model.setTitle(<span class="string">&quot;拼团活动&quot;</span>);</span><br><span class="line">		model.setShowState(GshoppingShowState.GSHOPPING_SHOW_STATE_0.resolve());<span class="comment">//显示状态 0:显示， 1：不显示</span></span><br><span class="line">		model.setGshoppingType(GshoppingType.GSHOPPING_TYPE_1.resolve());<span class="comment">//模块类型0：新人模块，1：拼团模块</span></span><br><span class="line">		<span class="comment">//成团时间转换秒</span></span><br><span class="line"><span class="comment">//		Long groupsTime = request.getGroupsTime() * DateUtil.SECOND_IN_DAY;</span></span><br><span class="line"><span class="comment">//		model.setPrescription(groupsTime);</span></span><br><span class="line">		model.setGshoppingState(GshoppingState.GSHOPPING_STATE_0.resolve());<span class="comment">//默认0为有效</span></span><br><span class="line">		model.setStartAt(request.getStartAt());</span><br><span class="line">		model.setExpiredAt(request.getExpiredAt());</span><br><span class="line">		model.setGshoppingNum(request.getGshoppingNum());</span><br><span class="line">		<span class="comment">//保存主表</span></span><br><span class="line">		Boolean isSuccess  = gshoppingInfoWriteService.create(model);</span><br><span class="line">		<span class="keyword">if</span> (isSuccess)&#123;</span><br><span class="line">			<span class="keyword">return</span> model.getId();</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">return</span>  <span class="keyword">null</span>;</span><br><span class="line">	&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>创建拼团活动成功根据返回的主键id创建拼团商品</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/***</span></span><br><span class="line"><span class="comment">	 * 保存模块商品关联表</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> request</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> id</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="function"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title">saveGshoppingItem</span><span class="params">(SpellGroupCreateRequest request, Long id)</span> </span>&#123;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">		<span class="comment">//start 保存模块商品关联表</span></span><br><span class="line">		GshoppingItemModel itemModel = <span class="keyword">new</span> GshoppingItemModel();</span><br><span class="line">		itemModel.setItemId(request.getItemId());</span><br><span class="line">		itemModel.setItemName(request.getItemName());<span class="comment">//调用商品查询商品名字</span></span><br><span class="line">		<span class="comment">//itemModel.setItemName(&quot; &quot;);//调用商品查询商品名字</span></span><br><span class="line">		itemModel.setGsId(id);</span><br><span class="line">		itemModel.setSort(<span class="number">0</span>);</span><br><span class="line">		itemModel.setPurchasingNum(request.getPurchasingNum());</span><br><span class="line">		itemModel.setPurchasingType(GshoppingType.GSHOPPING_TYPE_1.resolve());</span><br><span class="line">		itemModel.setUpdatedBy(request.getCreaterBy());</span><br><span class="line">		itemModel.setOperatorId(<span class="keyword">new</span> Long(request.getOperatorId()));</span><br><span class="line">		itemModel.setTenantId(<span class="keyword">new</span> Long(request.getTenantId()));</span><br><span class="line">		itemModel.setState(GshoppingState.GSHOPPING_STATE_0.resolve());</span><br><span class="line">		itemModel.setRemark(<span class="string">&quot;拼团活动&quot;</span>);</span><br><span class="line">		Boolean itemIsSuccess = gshoppingItemWriteService.create(itemModel);</span><br><span class="line">		<span class="comment">//end 保存模块商品关联表</span></span><br><span class="line">		<span class="keyword">if</span> (itemIsSuccess) saveGshoppingSku(request, id);</span><br><span class="line">	&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>创建拼团活动商品成功再去保存sku信息</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/***</span></span><br><span class="line"><span class="comment">	 * 保存SKU信息表</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> request</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> id</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="function"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title">saveGshoppingSku</span><span class="params">(SpellGroupCreateRequest request, Long id)</span> </span>&#123;</span><br><span class="line">		List&lt;GshoppingSkuModel&gt; models = Lists.newArrayList();</span><br><span class="line">		<span class="keyword">for</span> (SkuGroupInfo skuGroupInfo : request.getSkuGroupInfos())&#123;</span><br><span class="line">			GshoppingSkuModel gshoppingSkuModel = <span class="keyword">new</span> GshoppingSkuModel();</span><br><span class="line">			gshoppingSkuModel.setId(idGenerator.nextValue(GshoppingSkuModel.class,request.getOperatorId()));</span><br><span class="line">			gshoppingSkuModel.setGsId(id);</span><br><span class="line">			gshoppingSkuModel.setSkuId(skuGroupInfo.getSkuId());</span><br><span class="line">			gshoppingSkuModel.setItemId(request.getItemId());</span><br><span class="line">			gshoppingSkuModel.setPurchasingNum(request.getPurchasingNum());</span><br><span class="line">			gshoppingSkuModel.setPrice(skuGroupInfo.getPrice());</span><br><span class="line">			gshoppingSkuModel.setUpdatedBy(request.getCreaterBy());</span><br><span class="line">			gshoppingSkuModel.setOperatorId(request.getOperatorId());</span><br><span class="line">			gshoppingSkuModel.setTenantId(<span class="keyword">new</span> Long(request.getTenantId()));</span><br><span class="line">			gshoppingSkuModel.setState(GshoppingState.GSHOPPING_STATE_0.resolve());</span><br><span class="line">			gshoppingSkuModel.setShardNo(request.getOperatorId().toString());</span><br><span class="line">			gshoppingSkuModel.setRemark(<span class="string">&quot;拼团活动&quot;</span>);</span><br><span class="line"></span><br><span class="line">			models.add(gshoppingSkuModel);</span><br><span class="line">		&#125;</span><br><span class="line">		gshoppingSkuWriteService.createBatch(models);</span><br><span class="line">	&#125;</span><br></pre></td></tr></table></figure>

<h4 id="二、用户参团"><a href="#二、用户参团" class="headerlink" title="二、用户参团"></a>二、用户参团</h4><p><img src="C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211216164516832.png" alt="image-20211216164516832"></p>
<ul>
<li>点击我要参团跳转到订单确认页</li>
</ul>
<p><img src="C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211216164638137.png" alt="image-20211216164638137"></p>
<ul>
<li>点击确定渲染订单前校验拼团活动信息</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 判断拼团活动是否开团没开团系统自动开团</span></span><br><span class="line"><span class="comment"> * 参团校验拼团活动有效性</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> request</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">private</span> Long <span class="title">checkGroupExists</span><span class="params">(RenderOrderRequest request)</span> </span>&#123;</span><br><span class="line">    Long eventId = <span class="keyword">null</span>;</span><br><span class="line">    <span class="keyword">if</span> (request.getGsId() != <span class="keyword">null</span> &amp;&amp; request.getGsId() != <span class="number">0</span>) &#123;</span><br><span class="line">        GshoppingInfo gshoppingInfo = promotionService.getGshoppingInfo(request.getGsId(), request.getOperatorId());</span><br><span class="line">        log.info(<span class="string">&quot;===========怡通云拼团渲染订单时，获取拼团活动信息===========gshoppingInfo:&#123;&#125;&quot;</span>, gshoppingInfo);</span><br><span class="line">        <span class="keyword">if</span> (gshoppingInfo == <span class="keyword">null</span>) &#123;</span><br><span class="line">            <span class="comment">//拼团活动不存在</span></span><br><span class="line">            <span class="keyword">throw</span> <span class="keyword">new</span> BuyException(ErrorDomain.INTERNAL, <span class="string">&quot;gshopping.info.is.not.exist&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> (gshoppingInfo.getState() == <span class="number">4</span> || System.currentTimeMillis() &lt; gshoppingInfo.getStartAt().getTime()) &#123;</span><br><span class="line">            <span class="comment">//该拼团活动未开始</span></span><br><span class="line">            <span class="keyword">throw</span> <span class="keyword">new</span> BuyException(ErrorDomain.INTERNAL, <span class="string">&quot;gshopping.info.start.time.is.not.ing&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> (gshoppingInfo.getState() == <span class="number">2</span> || System.currentTimeMillis() &gt; gshoppingInfo.getExpiredAt().getTime()) &#123;</span><br><span class="line">            <span class="comment">//该商品拼团活动已经结束了，下次早点来哦！</span></span><br><span class="line">            <span class="keyword">throw</span> <span class="keyword">new</span> BuyException(ErrorDomain.INTERNAL, <span class="string">&quot;gshopping.info.end.time.is.end&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        BuySkuThinParam orderLine = request.getOrderLineList().get(<span class="number">0</span>);</span><br><span class="line">        <span class="keyword">if</span> (gshoppingInfo.getPurchasingNum() != <span class="keyword">null</span> &amp;&amp; gshoppingInfo.getPurchasingNum() &gt; <span class="number">0</span>) &#123;<span class="comment">//配置了限购数量</span></span><br><span class="line">            <span class="keyword">if</span> (orderLine.getQuantity() &gt; gshoppingInfo.getPurchasingNum()) &#123;</span><br><span class="line">                <span class="comment">//选购数量需小于限购数量！</span></span><br><span class="line">                <span class="keyword">throw</span> <span class="keyword">new</span> BuyException(ErrorDomain.INTERNAL, <span class="string">&quot;gshopping.info.item.quantity.limit&quot;</span>);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>校验通过判断该活动有没有开团没有或者已成团就新开团</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">List&lt;GshoppingEventInfo&gt; findGshoppingEventInfo = promotionService.findGshoppingEventByGsId(request.getGsId());</span><br><span class="line">           log.info(<span class="string">&quot;=====Collage Begin:====&gt; findGshoppingEventInfo:&#123;&#125;&quot;</span>, JSON.toJSONString(findGshoppingEventInfo));</span><br><span class="line">           <span class="keyword">if</span> (CollectionUtils.isEmpty(findGshoppingEventInfo) || attemptOpenGroup(findGshoppingEventInfo)) &#123;</span><br><span class="line">               log.info(<span class="string">&quot;:::::::::Open group ===============&gt; gsId:&#123;&#125; buyerId:&#123;&#125;&quot;</span>, gshoppingInfo.getId(), request.getBuyerId());</span><br><span class="line">               eventId = promotionService.createGshoppingEvent(gshoppingInfo.getId(), orderLine.getItemId(), orderLine.getSkuId(), request.getBuyerId(), gshoppingInfo.getOperatorId(), gshoppingInfo.getTenantId());</span><br></pre></td></tr></table></figure>

<ul>
<li>已成团判断</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">boolean</span> <span class="title">attemptOpenGroup</span><span class="params">(List&lt;GshoppingEventInfo&gt; gshoppingEventInfos)</span> </span>&#123;</span><br><span class="line">    List&lt;GshoppingEventInfo&gt; collect = gshoppingEventInfos.stream().filter(item -&gt; Objects.isNull(item.getConfirmTime())).collect(Collectors.toList());</span><br><span class="line">    <span class="keyword">return</span> CollectionUtils.isEmpty(collect);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>开团返回拼团id</p>
<ul>
<li>开团了点击确定就是参团，进行校验</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></td><td class="code"><pre><span class="line">log.info(<span class="string">&quot;----- join group =============&gt; eventId =&#123;&#125;,buyerId=&#123;&#125;,gsId=&#123;&#125;&quot;</span>, request.getEventId(), request.getBuyerId(), request.getGsId());</span><br><span class="line">                <span class="keyword">if</span> (request.getEventId() != <span class="keyword">null</span> &amp;&amp; request.getEventId() != <span class="number">0</span>) &#123;</span><br><span class="line">                    <span class="comment">//todo 参团</span></span><br><span class="line">                    GshoppingEventInfo gshoppingEventInfo = promotionService.getGshoppingEventInfo(request.getEventId(), request.getOperatorId());</span><br><span class="line">                    log.info(<span class="string">&quot;===========怡通云拼团渲染订单时，获取对应团信息===========gshoppingEventInfo:&#123;&#125;&quot;</span>, gshoppingEventInfo);</span><br><span class="line">                    <span class="keyword">if</span> (gshoppingEventInfo == <span class="keyword">null</span>) &#123;</span><br><span class="line">                        <span class="comment">//该团不存在</span></span><br><span class="line">                        <span class="keyword">throw</span> <span class="keyword">new</span> BuyException(ErrorDomain.INTERNAL, <span class="string">&quot;gshopping.event.code.is.not.exist&quot;</span>);</span><br><span class="line">                    &#125;</span><br><span class="line">                    <span class="keyword">if</span> (System.currentTimeMillis() &gt; gshoppingEventInfo.getEndTime().getTime() || Boolean.TRUE.equals(gshoppingEventInfo.getState())) &#123; <span class="comment">////状态0：有效，1：失效</span></span><br><span class="line">                        <span class="comment">//该团已经失效了，快去重新参与其他拼团吧。</span></span><br><span class="line">                        <span class="keyword">throw</span> <span class="keyword">new</span> BuyException(ErrorDomain.INTERNAL, <span class="string">&quot;gshopping.event.code.end.time.is.end&quot;</span>);</span><br><span class="line">                    &#125;</span><br><span class="line"></span><br><span class="line">                    <span class="keyword">if</span> (gshoppingEventInfo.getConfirmTime() != <span class="keyword">null</span>) &#123; <span class="comment">//已经成团</span></span><br><span class="line">                        <span class="comment">//该团已经被别人抢先一步拼咯，快去重新参与其他拼团吧。</span></span><br><span class="line">                        <span class="keyword">throw</span> <span class="keyword">new</span> BuyException(ErrorDomain.INTERNAL, <span class="string">&quot;gshopping.event.code.people.num.is.end&quot;</span>);</span><br><span class="line">                    &#125;</span><br><span class="line">                    <span class="comment">//查询已经成团的总人数</span></span><br><span class="line">                    List&lt;Long&gt; buyerList = orderBuyerReadFacade.getBuyerByEventId(request.getEventId(), request.getOperatorId()).getData();</span><br><span class="line">                    <span class="keyword">if</span> (buyerList.size() &gt;= gshoppingEventInfo.getPeopleNum()) &#123;</span><br><span class="line">                        <span class="comment">//该团已经被别人抢先一步拼咯，快去重新参与其他拼团吧。</span></span><br><span class="line">                        <span class="keyword">throw</span> <span class="keyword">new</span> BuyException(ErrorDomain.INTERNAL, <span class="string">&quot;gshopping.event.code.people.num.is.end&quot;</span>);</span><br><span class="line">                    &#125;</span><br><span class="line">                    <span class="keyword">if</span> (buyerList.contains(request.getBuyerId())) &#123;</span><br><span class="line">                        <span class="comment">//您已经参与该团了，不能重复参与！</span></span><br><span class="line">                        <span class="keyword">throw</span> <span class="keyword">new</span> BuyException(ErrorDomain.INTERNAL, <span class="string">&quot;gshopping.event.code.is.repeat&quot;</span>);</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br><span class="line"></span><br><span class="line">                List&lt;BuySkuThinParam&gt; orderLineList = request.getOrderLineList();</span><br><span class="line">                <span class="keyword">for</span> (BuySkuThinParam buySkuThinParam : orderLineList) &#123;</span><br><span class="line">                    <span class="keyword">if</span> (gshoppingInfo.getItemId().longValue() != buySkuThinParam.getItemId().longValue()) &#123;</span><br><span class="line">                        <span class="comment">//拼团活动未配置商品信息(SPU)</span></span><br><span class="line">                        <span class="keyword">throw</span> <span class="keyword">new</span> BuyException(ErrorDomain.INTERNAL, <span class="string">&quot;gshopping.info.item.is.null&quot;</span>);</span><br><span class="line">                    &#125;</span><br><span class="line">                    Optional&lt;GsSkuGroupInfo&gt; optional = gshoppingInfo.getSkuGroupInfos().stream().filter(s -&gt; s.getSkuId().longValue() == buySkuThinParam.getSkuId().longValue()).findFirst();</span><br><span class="line">                    <span class="keyword">if</span> (!optional.isPresent()) &#123;</span><br><span class="line">                        <span class="comment">//拼团活动未配置商品信息(SKU)</span></span><br><span class="line">                        <span class="keyword">throw</span> <span class="keyword">new</span> BuyException(ErrorDomain.INTERNAL, <span class="string">&quot;gshopping.info.item.is.null&quot;</span>);</span><br><span class="line">                    &#125;</span><br><span class="line">                    <span class="keyword">if</span> (gshoppingInfo.getPurchasingNum() != <span class="keyword">null</span> &amp;&amp; gshoppingInfo.getPurchasingNum() &gt; <span class="number">0</span>) &#123;<span class="comment">//配置了限购数量</span></span><br><span class="line">                        <span class="comment">//查询用户拼团活动的总数量</span></span><br><span class="line">                        log.info(<span class="string">&quot;======拼团渲染订单========&quot;</span> + request.getGsId() + <span class="string">&quot;====&quot;</span> + request.getBuyerId() + <span class="string">&quot;=======&quot;</span> + request.getOperatorId());</span><br><span class="line">                        Long count = orderBuyerReadFacade.getMyGshoppingItemCount(request.getGsId(), request.getBuyerId(), request.getOperatorId()).getData();</span><br><span class="line">                        <span class="keyword">if</span> (count &gt;= gshoppingInfo.getPurchasingNum()) &#123;</span><br><span class="line">                            <span class="comment">//您已经达到限购数量，无法继续购买！</span></span><br><span class="line">                            <span class="keyword">throw</span> <span class="keyword">new</span> BuyException(ErrorDomain.INTERNAL, <span class="string">&quot;gshopping.info.item.count.limit&quot;</span>);</span><br><span class="line">                        &#125;</span><br><span class="line">                        <span class="keyword">if</span> (count + buySkuThinParam.getQuantity() &gt; gshoppingInfo.getPurchasingNum()) &#123;</span><br><span class="line">                            <span class="comment">//选购数量需小于限购数量！</span></span><br><span class="line">                            <span class="keyword">throw</span> <span class="keyword">new</span> BuyException(ErrorDomain.INTERNAL, <span class="string">&quot;gshopping.info.item.quantity.limit&quot;</span>);</span><br><span class="line">                        &#125;</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br></pre></td></tr></table></figure>

<ol>
<li>根据拼团id获取拼团信息</li>
<li>根据拼团信息判断该团是否已成团或失效</li>
<li>根据拼团id和区域id查询订单获取支付成功的用户id</li>
<li>通过用户id信息判断该参团用户是否已参团和该团是否已满员</li>
<li>如果拼团活动设置了限购数量校验选购数量</li>
<li>通过拼团活动id和用户id查询获取该活动该用户的所有已支付订单</li>
<li>拿到所有已支付订单去订单行表查询该用户所有订单的购买总数</li>
<li>判断购买总数是否大于等于该活动限购件数超过则不能继续购买</li>
<li>没有达到修购数量则判断已购买数量加上选购数量是否大于该活动设置的限购数量若大于则不让下单</li>
</ol>
<h5 id="三、提交订单支付"><a href="#三、提交订单支付" class="headerlink" title="三、提交订单支付"></a>三、提交订单支付</h5><p><img src="C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211217141222782.png" alt="image-20211217141222782"></p>
<ul>
<li>提交订单并支付成功订单表保存用户id和拼团id</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//判断拼团订单</span></span><br><span class="line">              <span class="keyword">if</span>(buyContext.getGsId() != <span class="keyword">null</span> &amp;&amp; buyContext.getGsId() != <span class="number">0</span>)&#123;</span><br><span class="line"></span><br><span class="line">                  log.info(<span class="string">&quot;===========怡通云拼团订单DO参数===========orderCreateParam:&#123;&#125;&quot;</span>, JacksonSerializer.serialize(orderCreateParam));</span><br><span class="line"></span><br><span class="line">                  GshoppingInfo gshoppingInfo = promotionService.getGshoppingInfo(buyContext.getGsId(),buyContext.getEascsOperator().getOperatorId());</span><br><span class="line">                  log.info(<span class="string">&quot;===========怡通云拼团创建订单获取活动信息===========gshoppingInfo:&#123;&#125;&quot;</span>, JacksonSerializer.serialize(gshoppingInfo));</span><br><span class="line">                  <span class="keyword">if</span>(gshoppingInfo != <span class="keyword">null</span> &amp;&amp; gshoppingInfo.getState() == <span class="number">3</span>)&#123; <span class="comment">//状态 2=已结束 3=进行中 4=未开始</span></span><br><span class="line">                      orderCreateParam.setGsId(buyContext.getGsId());</span><br><span class="line">                      orderCreateParam.setGsUserId(gshoppingInfo.getUserId());</span><br><span class="line">                      <span class="keyword">if</span>(buyContext.getEventId() != <span class="keyword">null</span> &amp;&amp; buyContext.getEventId() != <span class="number">0</span>) &#123; <span class="comment">//参团</span></span><br><span class="line">                          orderCreateParam.setEventId(buyContext.getEventId());</span><br><span class="line">                          orderCreateParam.setEventCode(<span class="number">1</span>);</span><br><span class="line">                      &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">                          orderCreateParam.setEventId(orderCreateParam.getOrderId());</span><br><span class="line">                          orderCreateParam.setEventCode(<span class="number">0</span>);</span><br><span class="line">                      &#125;</span><br><span class="line"></span><br><span class="line">                      <span class="keyword">if</span>(gshoppingInfo.getOperatorId() != <span class="keyword">null</span> &amp;&amp; gshoppingInfo.getUserId() != <span class="keyword">null</span>)&#123;</span><br><span class="line">                          YjrRefereeQueryByUserIdRequest query = <span class="keyword">new</span> YjrRefereeQueryByUserIdRequest();</span><br><span class="line">                          query.setUserId(gshoppingInfo.getUserId());</span><br><span class="line">                          Response&lt;List&lt;YjrRefereeInfo&gt;&gt; response = yjrRefereeRelationsReadFacade.findByUserId(query);</span><br><span class="line">                          List&lt;YjrRefereeInfo&gt; userList = response.getResult();</span><br><span class="line">                          String levelCode = <span class="string">&quot;&quot;</span>;</span><br><span class="line">                          Boolean whiteUserFlag = Boolean.FALSE;</span><br><span class="line">                          <span class="keyword">if</span>(CollectionUtils.isNotEmpty(userList))&#123;</span><br><span class="line">                              levelCode = userList.get(<span class="number">0</span>).getPartnerLevelCode();</span><br><span class="line">                              <span class="keyword">if</span>(StringUtils.isNotBlank(userList.get(<span class="number">0</span>).getBuyPriceWhitelist()))&#123;</span><br><span class="line">                                  whiteUserFlag = <span class="string">&quot;1&quot;</span>.equals(userList.get(<span class="number">0</span>).getBuyPriceWhitelist());</span><br><span class="line">                              &#125;</span><br><span class="line">                          &#125;</span><br><span class="line">                          log.info(<span class="string">&quot;===========怡通云拼团活动创建人等级===========levelCode:&#123;&#125;&quot;</span>, levelCode);</span><br><span class="line">                          <span class="keyword">for</span> (OrderLineCreateParam orderLine : orderLines) &#123;</span><br><span class="line">                              AreaSkuQueryBySkuIdRequest skuReq = <span class="keyword">new</span> AreaSkuQueryBySkuIdRequest();</span><br><span class="line">                              skuReq.setSkuId(orderLine.getSku().getSkuId());</span><br><span class="line">                              skuReq.setOperatorId(gshoppingInfo.getOperatorId());</span><br><span class="line">                              AreaSkuInfo areaSkuInfo = areaSkuReadFacade.queryBySkuId(skuReq).getResult();</span><br><span class="line">                              log.info(<span class="string">&quot;===========怡通云拼团活动商品价格返回===========areaSkuInfo:&#123;&#125;&quot;</span>, JacksonSerializer.serialize(areaSkuInfo));</span><br><span class="line">                              <span class="keyword">if</span>(areaSkuInfo != <span class="keyword">null</span> &amp;&amp; StringUtils.isNotEmpty(levelCode)) &#123;</span><br><span class="line">                                  Long whiteListPrice = Optional.ofNullable(areaSkuInfo.getWhiteListPrice()).orElse(<span class="number">0L</span>);</span><br><span class="line">                                  Boolean whitePriceFlag = whiteListPrice &gt; <span class="number">0L</span> ? Boolean.TRUE : Boolean.FALSE;</span><br><span class="line">                                  <span class="keyword">if</span>(whiteUserFlag &amp;&amp; whitePriceFlag)&#123;</span><br><span class="line">                                      orderLine.setGsUserBuyprice(whiteListPrice);</span><br><span class="line">                                  &#125;<span class="keyword">else</span> <span class="keyword">if</span> (levelCode.equals(SettleYjrLevelRuleEnum.SETTLE_YJR_LEVEL_MEMBER.getCode()))&#123;</span><br><span class="line">                                      <span class="comment">//取会员等级价格</span></span><br><span class="line">                                      orderLine.setGsUserBuyprice(areaSkuInfo.getRegisterBuyPrice());</span><br><span class="line">                                  &#125;<span class="keyword">else</span> <span class="keyword">if</span> (levelCode.equals(SettleYjrLevelRuleEnum.SETTLE_YJR_LEVEL_V1_PARTNER.getCode())) &#123;</span><br><span class="line">                                      <span class="comment">//取V1购买价</span></span><br><span class="line">                                      orderLine.setGsUserBuyprice(areaSkuInfo.getV1Price());</span><br><span class="line">                                  &#125;<span class="keyword">else</span> <span class="keyword">if</span> (levelCode.equals(SettleYjrLevelRuleEnum.SETTLE_YJR_LEVEL_V2_PARTNER.getCode())) &#123;</span><br><span class="line">                                      <span class="comment">//取V2购买价</span></span><br><span class="line">                                      orderLine.setGsUserBuyprice(areaSkuInfo.getV2Price());</span><br><span class="line">                                  &#125;<span class="keyword">else</span> <span class="keyword">if</span> (levelCode.equals(SettleYjrLevelRuleEnum.SETTLE_YJR_LEVEL_V3_PARTNER.getCode())) &#123;</span><br><span class="line">                                      <span class="comment">//取v3购买价</span></span><br><span class="line">                                      orderLine.setGsUserBuyprice(areaSkuInfo.getDefaultPrice());</span><br><span class="line">                                  &#125;</span><br><span class="line">                              &#125;</span><br><span class="line"></span><br><span class="line">                          &#125;</span><br><span class="line">                      &#125;</span><br><span class="line">                  &#125;</span><br><span class="line">              &#125;</span><br><span class="line">          &#125;</span><br><span class="line">          log.info(<span class="string">&quot;===========怡通云创建订单组装后参数===========request:&#123;&#125;&quot;</span>, request);</span><br><span class="line">          orderBuyerWriteFacade.purchaseOrderCreate(request);</span><br></pre></td></tr></table></figure>

<ul>
<li>支付成功回调判断这笔支付是否可以立即成团</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">    * 必须要订单支付状态修改事务提交后，调用才有效</span></span><br><span class="line"><span class="comment">    *</span></span><br><span class="line"><span class="comment">    * <span class="doctag">@param</span> request</span></span><br><span class="line"><span class="comment">    * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">    */</span></span><br><span class="line">   <span class="meta">@Override</span></span><br><span class="line">   <span class="function"><span class="keyword">public</span> ApiResponse&lt;Boolean&gt; <span class="title">payCallBackGshopping</span><span class="params">(GshoppingOrderPayRequest request)</span> </span>&#123;</span><br><span class="line">       log.info(<span class="string">&quot;===========怡通云拼团订单支付成功回调触发===========request:&#123;&#125;&quot;</span>, JacksonSerializer.serialize(request));</span><br><span class="line">       <span class="comment">//查询当前订单是否为拼团订单</span></span><br><span class="line">       OrderGshoppingInfo orderGshoppingInfo = orderDao.getGshoppingOrderByOrderId(request.getOrderId(), request.getBuyerId());</span><br><span class="line">       log.info(<span class="string">&quot;===========怡通云拼团订单支付成功订单查询===========orderGshoppingInfo:&#123;&#125;&quot;</span>, JacksonSerializer.serialize(orderGshoppingInfo));</span><br><span class="line">       <span class="keyword">if</span> (orderGshoppingInfo != <span class="keyword">null</span> &amp;&amp; orderGshoppingInfo.getGsId() != <span class="keyword">null</span> &amp;&amp; orderGshoppingInfo.getEventId() != <span class="keyword">null</span>) &#123;</span><br><span class="line">           GshoppingEventInfo gshoppingEventInfo = promotionService.getGshoppingEventInfo(orderGshoppingInfo.getEventId(),orderGshoppingInfo.getOperatorId());</span><br><span class="line">           log.info(<span class="string">&quot;===========怡通云拼团订单支付成功促销团信息查询===========gshoppingEventInfo:&#123;&#125;&quot;</span>, JacksonSerializer.serialize(gshoppingEventInfo));</span><br><span class="line">           <span class="keyword">if</span> (gshoppingEventInfo == <span class="keyword">null</span>) &#123; <span class="comment">//没有数据，相当于开团</span></span><br><span class="line">               promotionService.createGshoppingEvent(orderGshoppingInfo.getEventId(), orderGshoppingInfo.getGsId(), orderGshoppingInfo.getEventCode(), orderGshoppingInfo.getItemId(), orderGshoppingInfo.getSkuId(), orderGshoppingInfo.getBuyerId(), orderGshoppingInfo.getBuyerName(),orderGshoppingInfo.getOperatorId(),orderGshoppingInfo.getTenantId());</span><br><span class="line">           &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">               <span class="keyword">if</span> (Boolean.FALSE.equals(gshoppingEventInfo.getState())) &#123; <span class="comment">// 状态0：有效，1：失效</span></span><br><span class="line">                   <span class="keyword">if</span> (gshoppingEventInfo.getConfirmTime() == <span class="keyword">null</span>) &#123;<span class="comment">//已经成团了，不做数据修改，按正常订单取消流程走</span></span><br><span class="line">                       <span class="comment">//参团，验证当前这笔支付是否可以立即成团</span></span><br><span class="line">                       List&lt;Long&gt; buyerList = orderDao.getBuyerByEventId(orderGshoppingInfo.getEventId(), orderGshoppingInfo.getOperatorId());</span><br><span class="line">                       <span class="keyword">if</span> (buyerList.size() &gt;= gshoppingEventInfo.getPeopleNum()) &#123; <span class="comment">//有效订单达到成团人数，立即成团</span></span><br><span class="line">                           promotionService.updatePayCallBackGshoppingEvent(orderGshoppingInfo.getEventId(),orderGshoppingInfo.getOperatorId(),buyerList);</span><br><span class="line">                       &#125;</span><br><span class="line">                   &#125;</span><br><span class="line">               &#125;</span><br><span class="line">           &#125;</span><br><span class="line">       &#125;</span><br><span class="line">       <span class="keyword">return</span> <span class="keyword">new</span> ApiResponse&lt;&gt;(Boolean.TRUE);</span><br><span class="line">   &#125;</span><br></pre></td></tr></table></figure>

<h5 id="四、拼团活动到期退款处理"><a href="#四、拼团活动到期退款处理" class="headerlink" title="四、拼团活动到期退款处理"></a>四、拼团活动到期退款处理</h5><ul>
<li>活动到期退款前判断该活动已成团数量时候大于1，成立则将进行中的团设置为已成团，否则走退款流程</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title">checkCollage</span><span class="params">(List&lt;Long&gt; gsIdList)</span> </span>&#123;</span><br><span class="line">       <span class="comment">//手动结束拼团</span></span><br><span class="line">       <span class="keyword">if</span> (!CollectionUtils.isEmpty(gsIdList)) &#123;</span><br><span class="line">           <span class="keyword">for</span> (Long gsId : gsIdList) &#123;</span><br><span class="line">               judgeAgglomerate(gsId);</span><br><span class="line">           &#125;</span><br><span class="line">       &#125;</span><br><span class="line">       <span class="comment">//获取活动结束时进行中的团</span></span><br><span class="line">       List&lt;GshoppingEventModel&gt; overEventInfo = gshoppingEventDao.getOverEventInfo();</span><br><span class="line">       <span class="keyword">if</span> (!CollectionUtils.isEmpty(overEventInfo)) &#123;</span><br><span class="line">           Set&lt;Long&gt; gsIds = overEventInfo.stream().map(GshoppingEventModel::getGsId).collect(Collectors.toSet());</span><br><span class="line">           log.info(<span class="string">&quot;======checkCollage__begin================&gt;,overEventInfo:&#123;&#125;,gsIds:&#123;&#125;&quot;</span>, JSON.toJSONString(overEventInfo), JSON.toJSONString(gsIds));</span><br><span class="line">           <span class="keyword">for</span> (Long gsId : gsIds) &#123;</span><br><span class="line">               judgeAgglomerate(gsId);</span><br><span class="line">           &#125;</span><br><span class="line">       &#125;</span><br><span class="line">   &#125;</span><br><span class="line"></span><br><span class="line">   <span class="function"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title">judgeAgglomerate</span><span class="params">(Long gsId)</span> </span>&#123;</span><br><span class="line">       <span class="comment">//根据活动id获取拼团信息</span></span><br><span class="line">       List&lt;GshoppingEventModel&gt; eventByGsId = gshoppingEventDao.getEventByGsId(gsId);</span><br><span class="line">       <span class="comment">//拼团成功信息</span></span><br><span class="line">       List&lt;GshoppingEventModel&gt; successGs = eventByGsId.stream().filter(item -&gt; Objects.nonNull(item.getConfirmTime())).collect(Collectors.toList());</span><br><span class="line">       log.info(<span class="string">&quot;-------------Collage_success_info ================&gt;,eventByGsId=&#123;&#125;,successGs=&#123;&#125;&quot;</span>, JSON.toJSONString(eventByGsId), JSON.toJSONString(successGs));</span><br><span class="line">       <span class="comment">//判断拼团成功的团数量是否大于等于1</span></span><br><span class="line">       <span class="keyword">if</span> (!CollectionUtils.isEmpty(successGs) &amp;&amp; successGs.size() &gt;= <span class="number">1</span>) &#123;</span><br><span class="line">           <span class="comment">//进行中状态的团置为拼团成功</span></span><br><span class="line">           List&lt;GshoppingEventModel&gt; conductGs = eventByGsId.stream().filter(item -&gt; Objects.isNull(item.getConfirmTime())).collect(Collectors.toList());</span><br><span class="line">           <span class="keyword">for</span> (GshoppingEventModel conductG : conductGs) &#123;</span><br><span class="line">               log.info(<span class="string">&quot;---------------progress_collage_info:::::::GshoppingEvent:&#123;&#125;&quot;</span>, JSON.toJSONString(conductG));</span><br><span class="line">               GshoppingEventModel gshoppingEventModel = <span class="keyword">new</span> GshoppingEventModel();</span><br><span class="line">               GshoppingOrderRequest gshoppingOrderRequest = <span class="keyword">new</span> GshoppingOrderRequest();</span><br><span class="line">               gshoppingOrderRequest.setOperatorId(conductG.getOperatorId());</span><br><span class="line">               gshoppingOrderRequest.setEventId(conductG.getId());</span><br><span class="line">               ApiResponse&lt;List&lt;Long&gt;&gt; result = gshoppingOrderFacade.getBuyerByEventId(gshoppingOrderRequest);</span><br><span class="line">               log.info(<span class="string">&quot;===========pay_success_user===========&gt;result:&#123;&#125;,eventId:&#123;&#125;&quot;</span>, JSON.toJSONString(result), conductG.getId());</span><br><span class="line">               List&lt;Long&gt; buyerList = result.getData();</span><br><span class="line">               <span class="keyword">if</span> (!CollectionUtils.isEmpty(buyerList)) &#123;</span><br><span class="line">                   String buyerIds = Joiner.on(<span class="string">&quot;,&quot;</span>).join(buyerList);</span><br><span class="line">                   gshoppingEventModel.setGsIds(buyerIds);</span><br><span class="line">               &#125;</span><br><span class="line">               gshoppingEventModel.setConfirmTime(<span class="keyword">new</span> Date());</span><br><span class="line">               gshoppingEventModel.setId(conductG.getId());</span><br><span class="line">               gshoppingEventModel.setShardNo(conductG.getShardNo());</span><br><span class="line">               gshoppingEventDao.update(gshoppingEventModel);</span><br><span class="line">           &#125;</span><br><span class="line">       &#125;</span><br><span class="line">   &#125;</span><br></pre></td></tr></table></figure>



<ul>
<li>使用定时任务每分钟查询一次到时间未成团的拼团进行退款</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="meta">@Override</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">autoRefundJob</span><span class="params">(PAutoRefundRequest request)</span> <span class="keyword">throws</span> ApiException </span>&#123;</span><br><span class="line">    <span class="comment">// 定时任务，每分钟跑一次</span></span><br><span class="line">    log.info(<span class="string">&quot;拼团自动退款定时任务开始&quot;</span>);</span><br><span class="line">    autoRefund(request);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="meta">@Override</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> ApiResponse&lt;Boolean&gt; <span class="title">autoRefund</span><span class="params">(PAutoRefundRequest request)</span> <span class="keyword">throws</span> ApiException </span>&#123;</span><br><span class="line">    List&lt;Long&gt; gsIds = request.getGsIds();</span><br><span class="line">    checkCollage(gsIds);</span><br><span class="line">    log.info(<span class="string">&quot;拼团自动退款gsIds：&#123;&#125;&quot;</span>, JSON.toJSONString(gsIds));</span><br><span class="line">    List&lt;GshoppingEventModel&gt; gshoppingEventModels = gshoppingEventDao.getEventIds(gsIds);</span><br><span class="line">    log.info(<span class="string">&quot;拼团自动退款ids：&#123;&#125;&quot;</span>, JSON.toJSONString(gshoppingEventModels));</span><br><span class="line">    <span class="keyword">if</span> (CollectionUtils.isNotEmpty(gshoppingEventModels)) &#123;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            AutoRefundRequest autoRefundRequest = <span class="keyword">new</span> AutoRefundRequest();</span><br><span class="line">            autoRefundRequest.setEventIds(gshoppingEventModels.stream().map(GshoppingEventModel::getId).collect(Collectors.toList()));</span><br><span class="line">            ApiResponse&lt;Boolean&gt; response = reverseReturnBuyerWriteFacade.autoRefund(autoRefundRequest);</span><br><span class="line">            log.info(<span class="string">&quot;拼团自动退款response：&#123;&#125;&quot;</span>, JSON.toJSONString(response));</span><br><span class="line">            <span class="keyword">if</span> (response.getData()) &#123;</span><br><span class="line">                <span class="keyword">for</span> (GshoppingEventModel model : gshoppingEventModels) &#123;</span><br><span class="line"></span><br><span class="line">                    GshoppingEventQueryRequest queryRequest = <span class="keyword">new</span> GshoppingEventQueryRequest();</span><br><span class="line">                    queryRequest.setId(model.getId());</span><br><span class="line">                    queryRequest.setShardNo(String.valueOf(model.getOperatorId()));</span><br><span class="line">                    Response&lt;GshoppingEventInfoResponse&gt; res = gshoppingEventReadFacade.view(queryRequest);</span><br><span class="line">                    <span class="keyword">if</span> (res != <span class="keyword">null</span> &amp;&amp; res.getResult() != <span class="keyword">null</span> &amp;&amp; res.getResult().getId() != <span class="keyword">null</span>) &#123;</span><br><span class="line">                        <span class="keyword">if</span> (Boolean.FALSE.equals(res.getResult().getState())) &#123;</span><br><span class="line">                            <span class="keyword">if</span> (res.getResult().getConfirmTime() == <span class="keyword">null</span>) &#123; <span class="comment">//防止定时任务过程中，突然成团，则不需要修改团状态</span></span><br><span class="line"></span><br><span class="line">                                GshoppingEventUpdateRequest updateRequest = <span class="keyword">new</span> GshoppingEventUpdateRequest();</span><br><span class="line">                                updateRequest.setId(model.getId());</span><br><span class="line">                                updateRequest.setState(<span class="keyword">true</span>);</span><br><span class="line">                                updateRequest.setShardNo(String.valueOf(model.getOperatorId()));</span><br><span class="line">                                gshoppingEventWriteFacade.update(updateRequest);</span><br><span class="line"></span><br><span class="line">                            &#125;</span><br><span class="line">                        &#125;</span><br><span class="line">                    &#125;</span><br><span class="line"></span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">new</span> ApiResponse&lt;&gt;(response.getData());</span><br><span class="line">        &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">            log.error(<span class="string">&quot;拼团自动退款异常：&quot;</span>, e);</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">new</span> ApiResponse&lt;&gt;((Boolean.FALSE));</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">new</span> ApiResponse&lt;&gt;(Boolean.TRUE);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


    </div>
<div>
  
    <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>

  
</div>

    
    
    
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://wan-lei8.gitee.io/2021/08/16/WorkSummary-Collage/" title="WorkSummary_Collage">https://wan-lei8.gitee.io/2021/08/16/WorkSummary-Collage/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/08/15/WorkSummary-Collage-Table-Design/" rel="prev" title="WorkSummary_Collage_Table_Design">
      <i class="fa fa-chevron-left"></i> WorkSummary_Collage_Table_Design
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/09/23/Redisson%E5%AE%9E%E7%8E%B0%E5%88%86%E5%B8%83%E5%BC%8F%E9%94%81/" rel="next" title="Redisson实现分布式锁">
      Redisson实现分布式锁 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E6%8B%BC%E5%9B%A2%E6%B5%81%E7%A8%8B"><span class="nav-number">1.</span> <span class="nav-text">拼团流程</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E7%94%A8%E6%88%B7%E5%8F%82%E5%9B%A2"><span class="nav-number">2.</span> <span class="nav-text">二、用户参团</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E6%8F%90%E4%BA%A4%E8%AE%A2%E5%8D%95%E6%94%AF%E4%BB%98"><span class="nav-number">2.1.</span> <span class="nav-text">三、提交订单支付</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E5%9B%9B%E3%80%81%E6%8B%BC%E5%9B%A2%E6%B4%BB%E5%8A%A8%E5%88%B0%E6%9C%9F%E9%80%80%E6%AC%BE%E5%A4%84%E7%90%86"><span class="nav-number">2.2.</span> <span class="nav-text">四、拼团活动到期退款处理</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt=""
      src="/images/avatar.png">
  <p class="site-author-name" itemprop="name"></p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives">
          <span class="site-state-item-count">41</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/yourname" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;yourname" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="/malegod958@163.com" title="E-Mail → malegod958@163.com"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>
  <div class="cc-license motion-element" itemprop="license">
    <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" class="cc-opacity" rel="noopener" target="_blank"><img src="/images/cc-by-nc-sa.svg" alt="Creative Commons"></a>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 2018 – 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">万磊</span>
</div>
  <div class="powered-by">

  </div>

        








      </div>
    </footer>
  </div>

  
  
  <script color='' opacity='0.5' zIndex='-1' count='99' src="/lib/canvas-nest/canvas-nest.min.js"></script>
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

  
	<script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>
	

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/src/clicklove.js"></script>
